<!--  -->
<template>
  <div class="bigbox">
    <div class="asddd">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="直播描述">
          <el-input v-model="form.miaoshu"></el-input>
        </el-form-item>
        <el-form-item label="封面图片">
          <el-upload
            class="avatar-uploader"
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload"
          >
            <img v-if="imageUrl" :src="imageUrl" class="avatar" />
            <i v-else class="el-icon-camera avatar-uploader-icon" />
          </el-upload>
        </el-form-item>
        <el-form-item label="直播模式">
          <el-radio-group v-model="form.resource">
            <el-radio label="横屏模式">
              <div class="wdaddd">
                <div class="vvvbbb">
                  <div class="el-icon-video-play iconiii"></div>
                </div>
              </div>
            </el-radio>
            <el-radio label="竖屏模式">
              <div class="hhhhh">
                <div class="jjjjj">
                  <div class="el-icon-video-play iconiii"></div>
                </div>
              </div>
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      imageUrl: "",
      form: {
        name: "",
        miaoshu: "",
        resource: ""
      }
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},

  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //方法集合
  methods: {
    onSubmit() {
      this.$router.push({ name: "Createlive", query: { list: this.form } });
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    }
  }
};
</script>
<style lang="scss" scoped>
.bigbox {
  width: 100%;
  height: 100%;
  padding: 20px;
}
.asddd {
  width: 500px;
  height: 600px;
}
.hhhhh {
  width: 100px;
  height: 50px;
  border: 1px solid #ccc;
  margin-left: 50px;
  .jjjjj {
    width: 70px;
    height: 50px;
    background: #ccc;
    margin-left: 15px;
    text-align: center;
    line-height: 55px;
    .iconiii {
      font-size: 24px;
    }
  }
}
.wdaddd {
  width: 100px;
  height: 50px;
  border: 1px solid #ccc;
  margin-left: 50px;
  .vvvbbb {
    width: 100%;
    height: 36px;
    background: #ccc;
    margin-top: 6px;
    text-align: center;
    line-height: 45px;
    .iconiii {
      font-size: 24px;
    }
  }
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  border: 1px solid #ccc;
}
.avatar {
  width: 38px;
  height: 38px;
  display: block;
}
</style>
